package com.wmjsoft.plugins.security.token

import com.wmjsoft.validator.BaseValidator
import com.wmjsoft.validator.anno.NotNull
import net.cloudopt.next.web.Resource
import net.cloudopt.next.web.route.API
import net.cloudopt.next.web.route.POST
import net.cloudopt.next.web.route.RequestBody

@API("/token")
class TokenController:Resource() {

    data class LoginVTO(
        @NotNull("用户名不能为空")
        var username: String? = null,
        @NotNull("密码不能为空")
        var password: String? = null
    ):BaseValidator() {
        override fun valid() {
            val any = this.params["password"]
            print(any)
        }
    }

    @POST("",valid = [LoginVTO::class])
    fun token(@RequestBody loginVTO: LoginVTO) {
        print(loginVTO)
        renderJson {
            template {
                parameters["result"] = "result"
            }
        }
    }
}

